package com.myidis.mapper;

import com.myidis.entity.*;
import com.myidis.request.SearchReq;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

public interface SignalLampResultMapper {
    @Select("SELECT * FROM signallamp_result_list}")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "subject", column = "subject"),
            @Result(property = "calTime", column = "calTime"),
            @Result(property = "combination", column = "combination"),
            @Result(property = "springDay", column = "springDay"),
            @Result(property = "calculator", column = "calculator"),
            @Result(property = "startTime", column = "startTime"),
            @Result(property = "endTime", column = "endTime")

    })
    ArrayList<IndexResultList> list();



    @Select("SELECT * FROM signallamp_result where listId = #{id}")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "listId", column = "listId"),
            @Result(property = "time", column = "time"),
            @Result(property = "combination", column = "combination"),
            @Result(property = "lamp", column = "lamp")
    })
    ArrayList<FullSLResult> getData(IndexResultList sea);

    @Select("SELECT * FROM signallamp_result where combination = #{combination}")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "listId", column = "listId"),
            @Result(property = "time", column = "time"),
            @Result(property = "combination", column = "combination"),
            @Result(property = "lamp", column = "lamp")
    })
    ArrayList<FullSLResult> getByCombination(String sea);


    @Select("SELECT * FROM signallamp_result_list where id = #{id}")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "subject", column = "subject"),
            @Result(property = "calTime", column = "calTime"),
            @Result(property = "combination", column = "combination"),
            @Result(property = "springDay", column = "springDay"),
            @Result(property = "calculator", column = "calculator"),
            @Result(property = "startTime", column = "startTime"),
            @Result(property = "endTime", column = "endTime")

    })
    FullSLResult getInfo(int sea);

    @Insert("INSERT intO signallamp_result(listId, time, lamp) VALUES( #{subject}, #{time}, #{lamp})")
    int insertDetail(FullSLResult set);

    @Insert("INSERT intO signallamp_result_list(subject, springDay, calTime, combination, calculator, startTime, endTime) VALUES(" +
            " #{subject},#{springDay}, #{calTime}, #{combination}, #{calculator}, #{startTime}, #{endTime})")
    int insertList(IndexResultList set);

    @Delete("DELETE FROM signallamp_result WHERE listId = #{id}")
    int deleteData(int id);

    @Delete("DELETE FROM signallamp_result_list WHERE id = #{id}")
    int delete(int id);
}
